﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<VideoInputModels>" %>

<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Lib.Paging" %>
<%@ Import Namespace="SDT.Admin.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Thêm video
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <%if (ViewData["MessageInfo"] == null)
      { %>
    <% using (Html.BeginForm("Create", "Video", FormMethod.Post, new
       {
           id = "adminForm",
           enctype = "multipart/form-data"
       }))
       {%>
    <%= Html.ValidationSummary(true)%>
    <table class="admintable" width="100%">
        <tbody>
            <tr>
                <td class="key">
                    Phân mục (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TreeViewList("CatID", Model.Categories, "-- Chuyên mục --", new { @class = "required" })%>
                </td>
            </tr>
            
            <tr>
                <td class="key">Chọn công ty</td>
                <td><%=Html.DropDownList("CompanyID", new SelectList(Model.Companies, "ID", "Name").ToList(),"-- Chọn công ty --")%></td>
            </tr>
            <tr>
                <td class="key">
                    Tiêu đề (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TextBox("Name", string.Empty, new { style = "width: 500px;", @class = "required" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Ảnh đại diện
                </td>
                <td>
                    <input type="file" name="ImagePath" id="ImagePath" value="" />
                </td>
            </tr>
            <tr>
                <td class="key">
                    Mã nhúng
                </td>
                <td>
                    <%=Html.TextArea("Code", string.Empty, new { style="width: 90%; height:50px" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Video
                </td>
                <td>
                    <input type="file" name="VideoPath" id="VideoPath" value="" />
                </td>
            </tr>
            <tr>
                <td class="key">
                    Mô tả
                </td>
                <td>
                    <%=Html.TextArea("Description", string.Empty, new { cols = 90, rows = 20 })%>
                </td>
            </tr>
            <tr>
                <td class="key">Chọn tag</td>
                <td>
                    <%= Html.TextBox("TagName", string.Empty, new {style = "width:350px" })%>
                    <%= Html.Hidden("TagID")%> (<font color="red">*</font>)Cho phép chọn nhiều tag, mỗi tag cách nhau bằng dấu ","
                </td> 
            </tr>            
            <tr>
                <td class="key">
                    Trạng thái hiển thị
                </td>
                <td>
                    <%= Html.RadioButton("PubYN", true, new { @checked = "checked" })%>
                    Đăng tin
                    <%= Html.RadioButton("PubYN", false)%>
                    Không đăng
                </td>
            </tr>
             <tr>
                <td class="key">
                    Trang chủ
                </td>
                <td>
                    <%= Html.RadioButton("HomeYN", true)%>
                    Hiển thị
                    <%= Html.RadioButton("HomeYN", false, new { @checked = "checked" })%>
                    Không hiển thị
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="hidden" id="AddDate" name="AddDate" value="<%= DateTime.Now %>" />
                    <input type="submit" id="btnSave" value="Thêm mới" onclick="return check_extension('ArticleImage','btnSave');" />
                </td>
            </tr>
        </tbody>
    </table>
    <%}
      } %>

    <script type="text/javascript">
        $(document).ready(function() {
            $("#adminForm").validate();
        });
        tinyMCE.init({
            mode: "exact",
            elements: "Description",
            theme: "advanced",
            plugins: "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,paste,imagemanager",
            theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "bottom",
            paste_use_dialog: false,
            paste_auto_cleanup_on_paste: true,
            paste_convert_headers_to_strong: false,
            paste_strip_class_attributes: "all",
            paste_remove_spans: true,
            paste_remove_styles: true
        });
        // Start Load du lieu Autocomplete for filed Select tag: Created by Vietlv//
        $("#TagName").autocomplete({
            minLength: 2,
            source: function(request, response) {
                $.ajax({
                    url: "/AjaxData/SearchTag",
                    dataType: "json",
                    data: {
                        keyword: extractLast(request.term)
                    },
                    success: function(data) {
                        response($.map(data, function(item) {
                            return {
                                label: item.Keyword,
                                value: item.Keyword,
                                id: item.ID
                            }
                        }));
                    }
                });
            },
            focus: function() {
                // prevent value inserted on focus
                return false;
            },
            select: function(event, ui) {
                var terms = split(this.value);
                // remove the current input
                terms.pop();
                // add the selected item
                terms.push(ui.item.value);
                // add placeholder to get the comma-and-space at the end
                terms.push("");
                this.value = terms.join(", ");

                var termsk = split($('#TagID').val());
                // remove the current input
                termsk.pop();
                // add the selected item
                termsk.push(ui.item.id);
                // add placeholder to get the comma-and-space at the end
                termsk.push("");
                $('#TagID').val(termsk.join(","));
                return false;
            }
        });
        // end
        // Start Addnew tag        
    </script>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <td>
    <%= Html.Toolbar("Quay lại", "/Video", "back")%>
    </td>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
	Thêm video
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
